package cc.orange.adapter;

import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;

import java.util.List;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import cc.orange.BuildConfig;
import cc.orange.R;
import cc.orange.entity.BaseEntity;
import cc.orange.utils.CircleImageView;
import demo.smart.access.xutlis.util.ZXSharedPrefUtil;


/**
 * Created by CM on 2022/10/25.
 */

public class MsgConA12Adapter extends BaseQuickAdapter<BaseEntity, BaseViewHolder> {
    ZXSharedPrefUtil sharedPrefUtil;//自己的头像
    public MsgConA12Adapter(@Nullable List<BaseEntity> data) {
        super(R.layout.rc_message_a12_item, data);
        sharedPrefUtil = new ZXSharedPrefUtil();
    }

    private String name,photo,uid;//对方的 姓名 头像 id
    public void setNamePhoto(String name,String photo,String uid){
        this.name = name;
        this.photo = photo;
        this.uid = uid;
    }
    @Override
    protected void convert(@NonNull BaseViewHolder helper, BaseEntity item) {
        CircleImageView rc_left_portrait = helper.getView(R.id.rc_left_portrait);
        CircleImageView rc_right_portrait = helper.getView(R.id.rc_right_portrait);
        RelativeLayout rc_content = helper.getView(R.id.rc_content);//
        RelativeLayout item_congv_rel2 = helper.getView(R.id.item_congv_rel2);//布局2 提示文字
        RelativeLayout item_congv_rel3 = helper.getView(R.id.item_congv_rel3);//布局3 带头像提示文字

        TextView  talk_msg_content = helper.getView(R.id.talk_msg_content); //消息文本
        TextView  rc_time = helper.getView(R.id.rc_time); //时间
        ImageView item_congv_a12_img1 = helper.getView(R.id.item_congv_a12_img1);

        RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
                ViewGroup.LayoutParams.WRAP_CONTENT);
        layoutParams.setMargins(0,20,0,0);
        talk_msg_content.setText("");
//        if(item.getClassify() == 0){
//            layoutParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
//            rc_content.setBackgroundResource(R.drawable.shape_msg_left);
//            talk_msg_content.setTextColor(mContext.getResources().getColor(R.color.black));
//            rc_left_portrait.setVisibility(View.VISIBLE);
//            rc_right_portrait.setVisibility(View.GONE);
//            Glide.with(mContext).load(photo).into(rc_left_portrait);
//        }else{
//            layoutParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
//            rc_content.setBackgroundResource(R.drawable.shape_msg_right);
//            talk_msg_content.setTextColor(mContext.getResources().getColor(R.color.black));
//            rc_left_portrait.setVisibility(View.GONE);
//            rc_right_portrait.setVisibility(View.VISIBLE);
//            String img_url = sharedPrefUtil.getString("url_hr", "");
//            Glide.with(mContext).load(img_url).into(rc_right_portrait);
//        }
//        rc_content.setLayoutParams(layoutParams);
//
//
//        String content = item.getChattingRecords();
//        content = content.replace("\n", " ");
//        if (content.length() > 100) {
//            content = content.substring(0, 100);
//        }
//        talk_msg_content.setText(new SpannableString(AndroidEmoji.ensure(content)));

        ZXSharedPrefUtil sharedPrefUtil = new ZXSharedPrefUtil();
        if (BuildConfig.UIA.equals("A1")) {// A1面
            item_congv_a12_img1.setImageResource(R.drawable.icon_home_a2_img6);
            rc_content.setBackgroundResource(R.drawable.shape_msg_right_a1);
        }else if (BuildConfig.UIA.equals("A2")){// A2面
            item_congv_a12_img1.setImageResource(R.drawable.icon_a12_msga2_img12);
            rc_content.setBackgroundResource(R.drawable.shape_msg_right_a2);
        }
    }
}
